library ViperScope initializer init 

	private function Trig_Viper_Scope_Conditions takes nothing returns boolean
		if ( not ( GetLearnedSkillBJ() == 'A08P' ) ) then
			return false
		endif
		return true
	endfunction

	private function Trig_Viper_Scope_Actions takes nothing returns nothing
		local unit u = GetTriggerUnit()
		local integer spell_level = GetUnitAbilityLevelSwapped(GetLearnedSkillBJ(), u)
		
		if(spell_level >1) then    
			call UnitAddAbilityBJ( 'A07D', u)
			call DisableTrigger(GetTriggeringTrigger())
		endif
		set u = null
	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
		call TriggerAddCondition( t, Condition( function Trig_Viper_Scope_Conditions ) )
		call TriggerAddAction( t, function Trig_Viper_Scope_Actions )
	endfunction

endlibrary